﻿Namespace Catalog
    Public Class Price
        Public Property Value As Double
        Public Property Currency As KeyValuePair(Of String, String)

        Public Sub New()
        End Sub

        Public Shared Function FromBPObject(pri As BPOPrice) As Price
            If pri Is Nothing Then Return Nothing
            Dim newPrice As New Price()

            newPrice.Value = pri.value / 100
            newPrice.Currency = New KeyValuePair(Of String, String)(pri.code, pri.symbol)

            Return newPrice
        End Function

        Public Overrides Function ToString() As String
            Return String.Format("{0:N2} {1}", Me.Value, Me.Currency.Value)
        End Function
    End Class
End Namespace